import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n=0;
        Scanner in=new Scanner(System.in);
        n=in.nextInt();
        for (int i = 1; i <= n; i++) {
            int sum =0;
            int we=0;
            int tmp=i;
            while(tmp>0){
                we++;
                tmp/=10;
            }
            tmp=i;
            while (tmp>0){
                int j=tmp%10;
                int swe=we;
                int ts=1;
                while(swe>0){
                    ts*=j;
                    swe--;
                }
                sum+=ts;
                tmp/=10;
            }
            if (sum==i){
                System.out.println(i);
            }
        }
        in.close();
    }





    public static void main2(String[] args) {
        int i=0;
        for (int j = 1; j < 100; j++) {
            int tmp=0;
            for (int k = 2; k < j; k++) {
                if (j%k==0){
                    tmp=1;
                    break;
                }
            }
            if (tmp==0)
                System.out.println(j);
        }
    }









    public static void main1(String[] args) {
        int count=0;
        for(int i=1;i<=100;i++) {
            int t=i;
            while(t>0) {
                if(t%10==9)
                    count++;
                t/=10;
            }
        }
        System.out.println(count);
    }
}